home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
misc
/
man2rtf
/
man2rtf.doc
< prev
next >
Wrap
Text File
|
1999-11-30
|
6KB
|
149 lines
Copyright 1990 by Norman Graham, Brandywine Softworks.
Permission to use, copy, modify, and distribte this software for
any purpose and without fee is hereby granted, provided that the
above copyright notice appear in all copies and that both the
copyright notice and this permission notice and warranty disclaimer
appear in supporting documentation, and that the name of Brandywine
Softworks or Norman Graham not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.
Brandywine Softworks and Norman Graham disclaim all warranties with
regard to this software, including all implied warranties of
merchantability and fitness. In no event shall Brandywine Softworks
or Norman Graham be liable for any special, indirect, or consequential
damages or any damages whatsoever resulting from loss of use, data,
or profits, whether in an action of contract, negligence, or other
tortious action, arising out of or in connection with the use or
performance of this software.
File: Man2RTF.c
Author: Norman Graham
Date: 2 September 1990
Usage: Man2RTF [-f|-h8|-h7] <Man.file >RTF.File
Description:
Man2RTF is a quick hack to convert a text file to Rich Text Format.
It converts some of the control sequences common in Un*x files into
the equivalent RTF character formatting. It converts the following
sequences:
"a\ba" => Bold 'a'
"a\ba\ba" => Bold 'a'
"a\ba\ba\ba" => Bold 'a'
"_\ba" => Underlined 'a'
"_\ba\ba" => Underlined Bold 'a'
"`" => Typographer's Opening Single Quote
"'" => Typographer's Closing Single Quote
Any other string with a '\b' in it is written to stderr as an error.
The idea is that Man2RTF will tell you when you need to extend it
to handle control sequences not currently handled.
Any non-control sequence is just copied to the RTF file.
Options:
-f Format the text with 10 point Courier and format the page
to display 66 lines on a vertical 8.5 inch by 11 inch page.
Margins are Top = 0.45 inch, Bottom = 0.45 inch, and
Left = 1.25 inches.
-h8 Format the text with 8 point Courier and format the page
to display two columns of 66 lines on a horizontal 8.5 inch
by 11 inch page. Margins are Top = 0.21 inch, Bottom = 0.21 inch,
Left = 0.15 inch, and Right = 0.15 inch with 0.15 inch between
columns. This format is not as useful as '-h7'.
-h7 Format the text with 7 point Courier and format the page
to display two columns of 66 lines on a horizontal 8.5 inch
by 11 inch page. Margins are Top = 0.9 inch, Bottom = 0.45 inch,
Left = 0.45 inch, and Right = 0.45 inch with 0.8 inch between
columns. This is a nice format because it provides a top margin
for binding and the space between columns is large enough that
you need not worry about the columns running together.
If no option is specified, Man2RTF will only generate font style
information; it will not generate font name, font size, or
page formating information.
Caveats:
If you use this tool on a Un*x box with the intention of
downloading the resulting file to your Mac, you need to
be aware that the resulting file probably contains typographer's
opening and closing quotes. These characters have values > 127
(i.e. their high bits are set), thus you'll need to make special
arangements to download the file. I'd suggest using mcvert
(available on sumex-aim) to convert the file to a macbinary
text file and then do a macbinary file transfer. As an alternative,
you could just nullify the typographer quote code by changing
kOpenSingleQuote to '`' and kCloseSingleQuote to '\''.
MPW build commands:
In MPW, you can build Man2RTF by executing the following commands
directly from this file. You'll need to edit the Link command
to put the tool where you want it and to repair the line continuation
characters that undoubtly will be munged by transport over the
internet.
C "{Active}"
Link -w -c 'MPS ' -t MPST 6
"{Active}".o 6
"{CLibraries}"StdClib.o 6
"{CLibraries}"CInterface.o 6
"{Libraries}"Stubs.o 6
"{CLibraries}"CRuntime.o 6
"{Libraries}"Interface.o 6
-o {MPW}Tools:LocalTools:Man2RTF
Delete "{Active}".o
Porting:
This program is written in ANSI C. If your compiler does not
support the ANSI C standard, you will need to modify this code.
Pay attention to the function prototypes, the new style function
definitions, and the string concatenation [used in calls to fprintf()
and puts()]. I believe most C compilers now support enum types,
but if yours doesn't you'll need to do some modifications here
as well.
For MPW users. Watch out for munged characters in the Link
command (from above) and in the definitions of kOpenSingleQuote
and kCloseSingleQuote. These definitions contain characters
that are > 127 (i.e. their high bit is set).
Bugs:
As with most quick hacks, the internals of this program are almost
completely undocumented. But it is a very simple program and
experienced C programmers should have no trouble following its
logic.
The following are some simple test strings:
Clear text _U_n_d_e_r_l_i_n_e_ _t_e_x_t Clear text
Clear text BBoolldd tteexxtt Clear text
Clear text _BB_oo_ll_dd_--_UU_nn_dd_ee_rr_ll_ii_nn_ee_ _tt_ee_xx_tt Clear text
Clear text BBBaaaddd ttteeexxxttt Clear text
Clear text B_Ba_ad_d _ t_te_ex_xt_t Clear text